from goods.models import GoodsCategory


def get_breadcrumb(category_id):
    # category_id  sku对应的三级分类id
    data = {
        "cat1": {},
        "cat2": {},
        "cat3": {}
    }
    cat3 = GoodsCategory.objects.get(id=category_id)
    data['cat3']['name'] = cat3.name
    data['cat2']['name'] = cat3.parent.name
    data['cat1']['name'] = cat3.parent.parent.name
    data['cat1']['url'] = cat3.parent.parent.goodschannel_set.first().url

    return data
